# 自定义异常类
class LenError(Exception):
    def __str__(self):
        # 　异常描述信息
        return '长度不合法'


# 　语法:
# 抛出异常
# raise 类名()

username = input('username:')
try:
    if (len(username) >= 6) and (len(username) <= 18):
        print('用户名合法')
    else:
        raise LenError()
except LenError as e:
    print(e)


